Thread: [Beginner] Monty Hall Guide Needed

  1. #1
    Registered User
    Join Date
    May 2014
    Posts
    3

    [Beginner] Monty Hall Guide Needed

    This my latest assignment for this week and urgh i don't how to solve this.. I totally have no idea..

    This is the QUESTION : Monty Hall problem - Simple English Wikipedia, the free encyclopedia

    Here is my sketch for the whole problem.

    imgur: the simple image sharer


    This is where I'm at so far, what should I do next?

    Code:
    #include <stdio.h>
    #include <stdlib.h> // rand() & srand() function
    #include <time.h> // rand() & srand() function
    #define MAX 3
    
    
    int main(void){
    
    
    	int i, door[3] = { 0, 0, 0}; 
    	int car, initialPick;
    
    
    	srand(time(NULL));
    		for( i = 0 ; i < 10 ; i++ ){					
    			
    			car = rand()%MAX+1; // place the car at the start using random number generator
    			initialPick = rand()%MAX+1; // stimulate contestant initial pick using random generator
    			
    			if ( rand()%2+1 = 1 ){
    					stays();
    			else  
    					repick();
    			}
    			printf("\n");
    		}
    
    
    		printf("The number of games played are %d and %lf win", i, );
    
    
    }
    Last edited by Nazrin Japiril; 05-11-2014 at 02:14 AM.

  2. #2
    Registered User
    Join Date
    Nov 2012
    Posts
    1,393
    Quote Originally Posted by Nazrin Japiril View Post
    This is the QUESTION : Monty Hall problem - Simple English Wikipedia, the free encyclopedia
    ...
    This is where I'm at so far, what should I do next?
    I think you should formulate this as a programming problem before going any further. A programming problem should be able to be written using this kind of formulation: "Write a program to simulate the Monty Hall problem. The input to your program is ... and the output is ..."

  3. #3
    Registered User
    Join Date
    May 2014
    Posts
    3
    OK , I'll try. I'm so frustrated because we haven't learn lots of stuff in class but we have to do this kind assignment ;(

  4. #4
    Registered User
    Join Date
    Nov 2012
    Posts
    1,393
    If you know your program will need to use features X, Y and Z, you could start by writing some minimal programs that use only those features. For example, if you know you will need to generate random numbers in your program but haven't done this before in C, then first write a simple program that only does that and nothing else.

  5. #5
    Registered User
    Join Date
    May 2014
    Posts
    3
    ^ Done that. I also had to learn about Array through uTube just now . But I don't think it's much of useful in this problem?

  6. #6
    Registered User
    Join Date
    Nov 2012
    Posts
    1,393
    Quote Originally Posted by Nazrin Japiril View Post
    But I don't think it's much of useful in this problem?
    It depends on what the problem is. See the earlier post. You need a problem statement before you know what the problem is.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Monty hall function problems
    By whiteboyfly in forum C Programming
    Replies: 8
    Last Post: 03-03-2014, 08:35 PM
  2. Beginner Question -- From Absolute Beginner's Guide to C
    By Dghelerter in forum C Programming
    Replies: 5
    Last Post: 12-26-2013, 01:30 PM
  3. Monty Hall Problem
    By tysawyers13 in forum C Programming
    Replies: 63
    Last Post: 11-04-2013, 12:09 AM
  4. Need Help with "Monty Hall" simulator program.
    By jsokol7 in forum C++ Programming
    Replies: 2
    Last Post: 10-03-2011, 11:54 PM
  5. MONTY HALL problem
    By jackalope in forum C Programming
    Replies: 10
    Last Post: 10-28-2010, 09:43 PM